package com.java.dao.impl;

import com.java.dao.AdminDao;
import com.java.domain.Admin;
import com.java.utils.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.SQLException;

public class AdminDaoImpl implements AdminDao {
    private QueryRunner runner = new QueryRunner(DruidUtils.getDataSource());
    String sql = "";


    @Override
    public Admin Login(Admin admin) {
        sql="select * from admin where admin_number = ? and admin_password = ?";
        try {
            return runner.query(sql,new BeanHandler<>(Admin.class),admin.getAdmin_number(),admin.getAdmin_password());
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return null;
    }

}
